<?php

class Application_Form_Test extends Zend_Form {

    public function init() {
        // Set the method for the display form to POST
        $this->setMethod('post');
        $this->setName('testform');

        // Add the comment element
        $this->addElement('text', 'name', array(
            'label' => 'Name:',
            'size' => 80,
            'required' => true,
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 300))
            )
        ));

        $level_id = new Zend_Form_Element_Select('level_id');
        $level_id->setLabel('Level')
                ->setRequired()
                ->addErrorMessage('Level required!');

        $levelOptions = new Application_Model_LevelMapper();
        foreach ($levelOptions->fetchAll() as $ind) {
            $level_id->addMultiOption($ind->getId(), $ind->getName());
        }

        $this->addElement($level_id);
        
        // Add the submit button
        $this->addElement('submit', 'submit', array(
            'ignore' => true,
            'label' => 'Save',
        ));


        // And finally add some CSRF protection
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));
    }

}

